<template>
	<div>
		<div style="border-bottom: 1px solid #eee;padding: 10px 10px 20px 10px;font-size: 14px;">
			<span style="font-weight: 550;">筛选：</span>
			<span style="margin-right: 5px;"><i class="el-icon-menu"></i></span>
			<span 
				class="itemSceneList"
				v-for="(item, index) in itemSceneList"
				:key="index"
				:class="activeIndex == index ? 'activeIndex' : ''"
				@click="onclick(item)">{{item.name}} | </span>
		</div>
		<div 
			v-if="statusList && statusList.length> 0"
			style="border-bottom: 1px solid #eee;padding: 10px 10px 20px 10px;font-size: 14px;">
			<span style="font-weight: 550;">状态：</span>
			<span style="margin-right: 5px;"><i class="el-icon-tickets"></i></span>
			<span 
				class="itemSceneList"
				v-for="(item, index) in statusList"
				:key="index"
				:class="sactiveIndex == index ? 'activeIndex' : ''"
				@click="onclickStatus(item)">{{item.name}} | </span>
		</div>
	</div>
	
</template>

<script>
	import { crmLawcaseStatusGet } from '@/api/lawcase/lawcase'
	import { crmContractStatusGet } from '@/api/contract/contract'
	export default {
		props: {
			// CRM类型
			crmType: {
			  type: String,
			  default: ''
			},
			actiontype: {
			  type:  [Number, String],
			  default: ''
			},
			scene_id: {
			  type: [Number, String],
			  default: ''
			}
		},
		data() {
			return {
				activeIndex:0,
				sactiveIndex:0,
				// 案件状态
				statusList:[]
			}
		},
		computed: {
			itemSceneList() {
				if(this.crmType == "customer") {
					return [
						{"activeIndex":0,"name":"全部"},
						{"activeIndex":1,"name":"我负责的客户"},
						{"activeIndex":2,"name":"我关注的客户"},
						{"activeIndex":3,"name":"我参与协助的"},
						{"activeIndex":4,"name":"今日新建"},
						{"activeIndex":5,"name":"本周新建"},
						{"activeIndex":6,"name":"本月新建"}
					]
				}else if(this.crmType == "lawcase") {
					switch (this.actiontype){
						case 9:
							// 开庭
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"今日开庭"},
								{"activeIndex":2,"name":"本周开庭"},
								{"activeIndex":3,"name":"已开庭"},
								{"activeIndex":4,"name":"已取消"}
							]
							break;
						case 10:
							// 判决
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"胜诉"},
								{"activeIndex":2,"name":"败诉"},
								{"activeIndex":3,"name":"中和判决"}
							]
							break;
						case 11:
							// 统计
							return [
								{"activeIndex":0,"name":"全部"}
							]
							break;
						case 12:
							// 客户反馈
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"未处理"},
								{"activeIndex":2,"name":"已处理（客户满意）"},
								{"activeIndex":3,"name":"已处理（客户不满意）"},
								{"activeIndex":4,"name":"其他"}
							]
							break;
						case 0:
							// 统计
							return [
								{"activeIndex":0,"name":"案件统计"},
								{"activeIndex":1,"name":"开庭统计"}
							]
							break;
						default:
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"我负责的案件"},
								{"activeIndex":2,"name":"我关注的案件"},
								{"activeIndex":3,"name":"诉讼案件"},
								{"activeIndex":4,"name":"刑事案件"},
								{"activeIndex":5,"name":"非诉服务"},
								{"activeIndex":6,"name":"非诉咨询"},
								{"activeIndex":7,"name":"今日新建"},
								{"activeIndex":8,"name":"本周新建"},
								{"activeIndex":9,"name":"本月新建"}
							]
							break;
					}
					
				}else if(this.crmType == "contract") {
					switch (this.actiontype){
						case 8:
							// 服务日志
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"今日服务"},
								{"activeIndex":2,"name":"本周服务"},
								{"activeIndex":3,"name":"本月服务"}
							]
							break;
						case 9:
							// 客户反馈
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"未处理"},
								{"activeIndex":2,"name":"已处理（客户满意）"},
								{"activeIndex":3,"name":"已处理（客户不满意）"},
								{"activeIndex":4,"name":"其他"}
							]
							break;
							
						case 0:
							// 统计
							return [
								{"activeIndex":0,"name":"服务日志统计"},
								// {"activeIndex":1,"name":"开庭统计"}
							]
							break;
							
							
						default:
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"我负责的"},
								{"activeIndex":2,"name":"我创建的"},
								{"activeIndex":3,"name":"今日签约"},
								{"activeIndex":4,"name":"本周签约"},
								{"activeIndex":5,"name":"本月签约"},
								{"activeIndex":6,"name":"有效期一年"},
								{"activeIndex":7,"name":"有效期二年"},
								{"activeIndex":8,"name":"有效期三年"},
								{"activeIndex":9,"name":"终止服务"}
							]
							break
					}
					
				}else if(this.crmType == "finance") {
					switch (this.actiontype){
						case 7:
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"未审核"},
								{"activeIndex":2,"name":"案件收费"},
								{"activeIndex":3,"name":"顾问收费"}
							]
							break;
							
						case 8:
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"案件应收款"},
								{"activeIndex":2,"name":"顾问应收款"}
							]
							break;
							
						case 9:
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"顾问发票"},
								{"activeIndex":2,"name":"案件发票"}
							]
							break;
							
						case 10:
							return [
								{"activeIndex":0,"name":"全部"},
								{"activeIndex":1,"name":"已审核"},
								{"activeIndex":2,"name":"未审核"},
								{"activeIndex":3,"name":"已付款"},
								{"activeIndex":4,"name":"已通过"},
								{"activeIndex":5,"name":"未通过"}
							]
							break;
						default:
							break;
					}
				}
			}
			
		},
		mounted() {
			let arr = [0,8,9,10,11,12]//案件
			let arr1 = [0,8,9]//顾问
			if(this.crmType == "lawcase" && !arr.includes(this.actiontype)) {
				crmLawcaseStatusGet().then((res) => {
					this.statusList = res.data
				}).catch(() => {})
			}
			
			if(this.crmType == "contract" && !arr1.includes(this.actiontype)) {
				crmContractStatusGet().then((res) => {
					this.statusList = res.data
				}).catch(() => {})
			}
		},
		methods: {
			onclick(item){
				this.activeIndex = item.activeIndex
				this.$emit("on-handle",item.activeIndex)
			},
			
			onclickStatus(item){
				this.sactiveIndex = item.activeIndex
				this.$emit("on-handle",item.name,"status")
			},
		}
	}
</script>

<style scoped>
	.itemSceneList{
		margin-right: 5px;
		cursor: pointer;
		line-height: 25px;
	}
	.activeIndex{
		color: #b5060d;
	}
</style>